package com.sheledon.flyCat.core.configuration.resolver;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Properties;

/**
 * @author sheledon
 */
public class PropertiesResolver implements Resolver{

    @Override
    public HashMap<String,Object> resolve(InputStream resource) {
        HashMap<String,Object> map = new HashMap<>();
        Properties properties = new Properties();
        try {
            properties.load(resource);
            properties.stringPropertyNames().forEach(name->{
                map.put(name,properties.getProperty(name));
            });
        } catch (IOException e) {
            e.printStackTrace();
        }
        return map;
    }

}
